from drf_yasg.utils import swagger_auto_schema
from rest_framework import viewsets, mixins, status
from rest_framework.decorators import action
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework import serializers

from api.utils.mixins import PermissionsPerMethodMixin
from api.models.hello import Hello

from api.utils.common import with_common_response, paginate_list


class HelloSerializer(serializers.ModelSerializer):
    class Meta:
        model = Hello
        fields = "__all__"


class HelloWord(PermissionsPerMethodMixin, viewsets.GenericViewSet, mixins.ListModelMixin):
    # authentication_classes = IstioJWTAuthentication
    queryset = Hello.objects.all()
    serializer_class = HelloSerializer

    # @swagger_auto_schema(operation_summary="hello word", operation_description="hello word")
    # def list(self, request):
    #
    #     return Response({"hello": "world new version"}, status=status.HTTP_200_OK)
    @swagger_auto_schema(
        method="get",
        operation_summary="hello word",
        operation_description="hello word",
        query_serializer=HelloSerializer,
        responses=with_common_response({status.HTTP_200_OK: HelloSerializer}),
    )
    @action(methods=["get"], url_name="word", url_path="word", detail=False)
    def get_hello(self, request):
        return Response("ok")
